package com.zian.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data;
import lombok.Getter;

@Getter
public enum DefaultFlagEnum {
    NO(0,"非默认"),
    YES(1,"默认");

    @EnumValue
    @JsonValue
    private final int code;
    private final String name;

    DefaultFlagEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(int code) {
        for (DefaultFlagEnum item : DefaultFlagEnum.values()) {
            if (item.getCode() == code) {
                return item.getName();
            }
        }
        return null;
    }
    public static DefaultFlagEnum getByCode(int code) {
        for (DefaultFlagEnum item : DefaultFlagEnum.values()) {
            if (item.getCode() == code) {
                return item;
            }
        }
        return null;
    }
}
